package SpringBoot.__template.full.config;

import java.io.IOException;

import org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.titan.core.web.utils.SpringBootUtils;

import SpringBoot.__template.full.config.startup.ApplicationContextAwareStartup;
import SpringBoot.__template.full.config.startup.FilterStartup;
import SpringBoot.__template.full.config.startup.HttpServletStartup;
//import SpringBoot.__template.full.config.startup.ServletContextListenerStartup;

/**
 *
 *
 * @author 周成功
 *
 */
@Configuration
public class JavaConfig {
    @Bean
    public EmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() throws IOException {
        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
        return tomcat;
    }
    
//    @Bean
//    public ApplicationContextAware startupSpring(){
//        return new ApplicationContextAwareStartup();
//    }
    
//    @Bean
//    public ServletListenerRegistrationBean startupListener(){
//        return SpringBootUtils.registerListener(ServletContextListenerStartup.class);
//    }
    
    @Bean
    public ServletRegistrationBean startupServlet() {
        return SpringBootUtils.registerServlet(HttpServletStartup.class, null, "/servlet");
    }
    
    @Bean
    public FilterRegistrationBean filterRegistrationBean() {  
        return SpringBootUtils.registerFilter(990, FilterStartup.class, null, "/*");
    }    
}
